import { ecs } from "db://app-game/libs/ecs/ECS";
import { DBLittleMonster } from "../../../common/db/db-little-monster/DBLittleMonster";
import { DBLittleMonsterType } from "../../../common/db/db-little-monster/DBLittleMonster.type";

/** 小怪基础信息组件 */
@ecs.register("LittleMonsterModel")
export class LittleMonsterModelComp extends ecs.Comp {
  db: DBLittleMonster = new DBLittleMonster();
  /** 用户Id */
  userId: number = -1;
  _id: number = -1;
  /** 角色编号 */
  get id(): number {
    return this._id;
  }
  set id(val: number) {
    this._id = val;
    this.db.init(val);
    this.data = this.db.data;
  }

  /** 小怪节点 */
  node: Node = null!;
  /** 小怪数据 */
  data: DBLittleMonsterType = null!;

  reset(entity: ecs.Entity): void {
    this._id = -1;
    this.node = null!;
    this.data = null!;
  }
}
